﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace DVRMS_Renamer
{
    public class FileList
    {
        private List<File> colFile = new List<File>();

        public void Add(File file)
        {
            colFile.Add(file);
        }

        public void AddRange(List<File> files)
        {
            colFile.AddRange(files);
        }

        public List<File> Clone()
        {
            return colFile.ToList();
        }

        public void Clear()
        {
            colFile = new List<File>();
        }

        public int Count
        {
            get
            {
                return colFile.Count;
            }
        }

        public File Item(int i)
        {
            return colFile[i];
        }

        public MyFileEnumerator GetEnumerator()
        {
            return new MyFileEnumerator(this);
        }
    }

    public class File
    {
        private string m_originalFileName;
        private string m_filePath;

        public string newFilename;
        public int confidence;
        public string url;
        public string urlCaption;
        public string showTitle;
        public DateTime originalBroadcast;
        public string subTitle;
        public string subTitleDescription;

        public bool remove = false;

        public File()
        {
            newFilename = "Not matched";
        }

        public string originalFileName
        {
            get
            {
                return m_originalFileName;
            }
            set
            {
                // Split into path and file
                m_filePath = Path.GetDirectoryName(Path.GetFullPath(value));
                m_originalFileName = Path.GetFileName(value);
            }
        }

        public string sourcePath
        {
            get
            {
                return m_filePath + "\\";
            }
        }

        public string confidenceDisplay
        {
            get
            {
                return confidence.ToString() + "%";
            }
        }
    }

    // Enumerator class
    public class MyFileEnumerator
    {
        int nIndex;
        FileList collection;

        public MyFileEnumerator(FileList coll)
        {
            collection = coll;
            nIndex = -1;
        }

        public bool MoveNext()
        {
            nIndex++;
            return (nIndex < collection.Count);
        }

        public File Current
        {
            get
            {
                return (collection.Item(nIndex));
            }
        }
    }
}
